import axios from "axios";
import qs from "qs";

const service = axios.create({
    timeout: 3000,
    headers: {
        "Content-Type": "application/json",
    },
});
service.interceptors.request.use(
    (config) => {
        if (config.method != undefined) {
            if (["get", "delete"].includes(config.method)) {
                config.url = config.url + "?" + qs.stringify(config.params);
                config.params = null;
                config.data = null;
            }
        }
        return config;
    },
    (error) => {
        Promise.reject(error);
    }
);

export default service;
